<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %}</title>
    <link rel="stylesheet" href="../static/layui/css/layui.css" />
    {% block css %}{% endblock %}
</head>
<body bgcolor="#F0FFF0">
<!--<div style="position:fixed; width: 100%;z-index: 99999;margin-right: 5px;">-->
    <!--<ul class="layui-nav">-->
        <!--<li class="layui-nav-item">-->
            <!--<a href="/index">首页</a>-->
        <!--</li>-->
        <!--<li class="layui-nav-item">-->
            <!--<a>Write</a>-->
            <!--<dl class="layui-nav-child" id="category"></dl>-->
        <!--</li>-->
        <!--<li class="layui-nav-item layui-layout-right" style="margin-right: 20px;">-->
            <!--<a id="nickname"></a>-->
            <!--<dl class="layui-nav-child">-->
                <!--<dd><a style="text-align: center;" href="/user/personalCenter">个人中心</a></dd>-->
                <!--<dd><a style="text-align: center;" id="updatePwd">修改信息</a></dd>-->
                <!--<dd><a href="/user/logout" style="text-align: center" id="logout">注销</a></dd>-->
            <!--</dl>-->
        <!--</li>-->
    <!--</ul>-->
<!--</div>-->

<div style="position:fixed;padding: 2% 2%">
    <div style="align-items: center" id="nickname">
    </div><br>
    <div class="layui-card-header">
        <a href="/user/logout" style="text-align: center" id="logout">注销</a><br>
    </div>
    <div class="layui-card-header">
        <a href="/index">首页</a>
        <a>|</a>
        <a style="text-align: center;" href="/user/personalCenter">个人中心</a>
    </div>
    <div class="layui-card-body" id="category"></div>

</div>

<div style="padding: 20px 20%">
{% block content %}
{% endblock %}
</div>
<script src="../static/layui/layui.js"></script>
{% block js %}{% endblock %}
<script>
    layui.use(["jquery","element"],function () {
        var $ = layui.jquery;
        var element = layui.element;

        $("#nickname").append('<img style="height: 100px;width: 100px;" src="'+localStorage.getItem("avatar")+'" class="layui-nav-img" />');

        $.ajax({
            type: "GET",
            url: "/admin/categoryList",
            data: {},
            success: function(res){
                let category = $("#category");
                for(i=0;i<res.data.length;i++){
                    html = '<a style="text-align: center;" href="/admin/editor?categoryId='+res.data[i].categoryId+'">写'+res.data[i].categoryName+'</a><br><br>';
                    category.append(html)
                }
            }
        });

        $(document).on("click","#userInfo",function(){
            layer.open({
                type:2
                ,title: "个人中心"
                ,area: ["500px","400px"]
                ,content: "/user/getUserInfo"
            });
        });

        $(document).on("click","#updatePwd",function () {
            layer.open({
                type:2
                ,title: "个人中心"
                ,area: ["500px","400px"]
                ,content: "/user/updatePassword"
            });
        });

        $(document).on("click","#logout",function () {
            localStorage.clear();
        })
    })
</script>
</body>
</html>